﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Phone="clr-namespace:WindowsPhoneMVC.Phone"
                    xmlns:Controls="clr-namespace:WindowsPhoneMVC.Controls">
    <Style TargetType="Phone:MvcFrame">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Phone:MvcFrame">
                    <Grid>
                        <Controls:PerformanceProgressBar x:Name="PART_ProgressIndicator"
                                                         IsLoading="False"
                                                         Visibility="Collapsed"
                                                         VerticalAlignment="Top"
                                                         HorizontalAlignment="Stretch"/>
                        <StackPanel HorizontalAlignment="Stretch"
                                    VerticalAlignment="Center"
                                    IsHitTestVisible="False">
                            <Controls:PerformanceProgressBar IsLoading="{TemplateBinding ShowProgressBar}"
                                                             Visibility="{TemplateBinding ProgressBarVisibility}"
                                                             HorizontalAlignment="Stretch" />
                            <ContentPresenter HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Content="{TemplateBinding LoadingMessage}"
                                              Visibility="{TemplateBinding ProgressBarVisibility}" />
                        </StackPanel>

                        <ContentControl IsHitTestVisible="{TemplateBinding IsContentEnabled}"
                                        Opacity="{TemplateBinding ContentOpacity}"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Stretch"
                                        HorizontalContentAlignment="Stretch"
                                        VerticalContentAlignment="Stretch">
                            <ContentPresenter x:Name="PART_MainContent"
                                                Content="{TemplateBinding Content}" />
                        </ContentControl>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
-->
    <Style TargetType="Controls:PerformanceProgressBar">
        <!-- This control only benefits indeterminate situations so it is only
             designed for that. -->
        <Setter Property="IsIndeterminate"
                Value="False" />
        <Setter Property="Foreground"
                Value="{StaticResource PhoneAccentBrush}" />
        <Setter Property="Background"
                Value="{StaticResource PhoneAccentBrush}" />
        <Setter Property="IsHitTestVisible"
                Value="False" />
        <Setter Property="Padding"
                Value="{StaticResource PhoneHorizontalMargin}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Controls:PerformanceProgressBar">
                    <Controls:RelativeAnimatingContentControl HorizontalContentAlignment="Stretch"
                                                              VerticalContentAlignment="Stretch">
                        <Controls:RelativeAnimatingContentControl.Resources>
                            <ExponentialEase EasingMode="EaseOut"
                                             Exponent="1"
                                             x:Key="ProgressBarEaseOut" />
                            <ExponentialEase EasingMode="EaseIn"
                                             Exponent="1"
                                             x:Key="ProgressBarEaseIn" />
                        </Controls:RelativeAnimatingContentControl.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Determinate" />
                                <VisualState x:Name="Indeterminate">
                                    <!-- Removed: RepeatBehavior="Forever" -->
                                    <Storyboard Duration="00:00:04.4">
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="IndeterminateRoot">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                       Storyboard.TargetName="DeterminateRoot">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0"
                                                                       Storyboard.TargetProperty="X"
                                                                       Storyboard.TargetName="R1TT">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0"
                                                                  Value="0.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.5"
                                                                  Value="33.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseOut}" />
                                            <LinearDoubleKeyFrame KeyTime="00:00:02.0"
                                                                  Value="66.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:02.5"
                                                                  Value="100.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseIn}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2"
                                                                       Storyboard.TargetProperty="X"
                                                                       Storyboard.TargetName="R2TT">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0"
                                                                  Value="0.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.5"
                                                                  Value="33.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseOut}" />
                                            <LinearDoubleKeyFrame KeyTime="00:00:02.0"
                                                                  Value="66.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:02.5"
                                                                  Value="100.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseIn}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4"
                                                                       Storyboard.TargetProperty="X"
                                                                       Storyboard.TargetName="R3TT">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0"
                                                                  Value="0.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.5"
                                                                  Value="33.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseOut}" />
                                            <LinearDoubleKeyFrame KeyTime="00:00:02.0"
                                                                  Value="66.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:02.5"
                                                                  Value="100.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseIn}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6"
                                                                       Storyboard.TargetProperty="X"
                                                                       Storyboard.TargetName="R4TT">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0"
                                                                  Value="0.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.5"
                                                                  Value="33.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseOut}" />
                                            <LinearDoubleKeyFrame KeyTime="00:00:02.0"
                                                                  Value="66.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:02.5"
                                                                  Value="100.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseIn}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8"
                                                                       Storyboard.TargetProperty="X"
                                                                       Storyboard.TargetName="R5TT">
                                            <LinearDoubleKeyFrame KeyTime="00:00:00.0"
                                                                  Value="0.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:00.5"
                                                                  Value="33.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseOut}" />
                                            <LinearDoubleKeyFrame KeyTime="00:00:02.0"
                                                                  Value="66.1" />
                                            <EasingDoubleKeyFrame KeyTime="00:00:02.5"
                                                                  Value="100.1"
                                                                  EasingFunction="{StaticResource ProgressBarEaseIn}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0"
                                                                       Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="R1">
                                            <DiscreteDoubleKeyFrame KeyTime="0"
                                                                    Value="1" />
                                            <DiscreteDoubleKeyFrame KeyTime="00:00:02.5"
                                                                    Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2"
                                                                       Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="R2">
                                            <DiscreteDoubleKeyFrame KeyTime="0"
                                                                    Value="1" />
                                            <DiscreteDoubleKeyFrame KeyTime="00:00:02.5"
                                                                    Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4"
                                                                       Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="R3">
                                            <DiscreteDoubleKeyFrame KeyTime="0"
                                                                    Value="1" />
                                            <DiscreteDoubleKeyFrame KeyTime="00:00:02.5"
                                                                    Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6"
                                                                       Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="R4">
                                            <DiscreteDoubleKeyFrame KeyTime="0"
                                                                    Value="1" />
                                            <DiscreteDoubleKeyFrame KeyTime="00:00:02.5"
                                                                    Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8"
                                                                       Storyboard.TargetProperty="Opacity"
                                                                       Storyboard.TargetName="R5">
                                            <DiscreteDoubleKeyFrame KeyTime="0"
                                                                    Value="1" />
                                            <DiscreteDoubleKeyFrame KeyTime="00:00:02.5"
                                                                    Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid>
                            <!-- This control does not function in Determinate -->
                            <Grid x:Name="DeterminateRoot"
                                  Margin="{TemplateBinding Padding}"
                                  Visibility="Visible" />
                            <Border x:Name="IndeterminateRoot"
                                    Margin="{TemplateBinding Padding}"
                                    Visibility="Collapsed">
                                <Grid HorizontalAlignment="Left">
                                    <Rectangle Fill="{TemplateBinding Foreground}"
                                               Height="4"
                                               IsHitTestVisible="False"
                                               Width="4"
                                               x:Name="R1"
                                               Opacity="0"
                                               CacheMode="BitmapCache">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="R1TT" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Rectangle Fill="{TemplateBinding Foreground}"
                                               Height="4"
                                               IsHitTestVisible="False"
                                               Width="4"
                                               x:Name="R2"
                                               Opacity="0"
                                               CacheMode="BitmapCache">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="R2TT" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Rectangle Fill="{TemplateBinding Foreground}"
                                               Height="4"
                                               IsHitTestVisible="False"
                                               Width="4"
                                               x:Name="R3"
                                               Opacity="0"
                                               CacheMode="BitmapCache">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="R3TT" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Rectangle Fill="{TemplateBinding Foreground}"
                                               Height="4"
                                               IsHitTestVisible="False"
                                               Width="4"
                                               x:Name="R4"
                                               Opacity="0"
                                               CacheMode="BitmapCache">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="R4TT" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                    <Rectangle Fill="{TemplateBinding Foreground}"
                                               Height="4"
                                               IsHitTestVisible="False"
                                               Width="4"
                                               x:Name="R5"
                                               Opacity="0"
                                               CacheMode="BitmapCache">
                                        <Rectangle.RenderTransform>
                                            <TranslateTransform x:Name="R5TT" />
                                        </Rectangle.RenderTransform>
                                    </Rectangle>
                                </Grid>
                            </Border>
                        </Grid>
                    </Controls:RelativeAnimatingContentControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>